/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package proy1sistdistribuidos.modelo.seguridad;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.math.BigInteger;

/**
 * Clase que almacena los datos necesarios para el intercambio de datos de Diffie-Hellman
 * @author Carlos Diaz Maya, Juan Felipe Garcia
 */
public class InformacionSocketDF {
    private byte[] dato;
    private String id;
    private BigInteger dato1;
    private BigInteger dato2;
    private int dato3;
    @XStreamOmitField
    private XStream xstream;

    public InformacionSocketDF() {
         if(xstream == null){
            xstream = new XStream(new DomDriver());
            registrarClasesXML(xstream);
        }
    }

    public InformacionSocketDF(String infoXML) {
        if(xstream == null){
            xstream = new XStream(new DomDriver());
            registrarClasesXML(xstream);
        }
        InformacionSocketDF info = (InformacionSocketDF) xstream.fromXML(infoXML);
        this.id = info.getId();
        this.dato = info.getDato();
        this.dato1 = info.getDato1();
        this.dato2 = info.getDato2();
    }


    /**
     * @return the dato
     */
    public byte[] getDato() {
        return dato;
    }

    /**
     * @param dato the dato to set
     */
    public void setDato(byte[] dato) {
        this.dato = dato;
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    private void registrarClasesXML(XStream xstream) {
        xstream.alias("InformacionSocket", InformacionSocketDF.class);
        xstream.omitField(this.getClass(), "xstream");
    }

    public String aXMLString(){
        return xstream.toXML(this);
    }

    public BigInteger getDato1() {
        return dato1;
    }

    public void setDato1(BigInteger dato1) {
        this.dato1 = dato1;
    }

    public BigInteger getDato2() {
        return dato2;
    }

    public void setDato2(BigInteger dato2) {
        this.dato2 = dato2;
    }

}
